package com.cf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cf.domain.pojo.News;
import com.cf.domain.vo.TeamVO;
import com.cf.mapper.NewsMapper;
import com.cf.service.INewsService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author lzqinga@126.com
 * @Date 2024/11/14  11:24
 */
@Service
@RequiredArgsConstructor
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements INewsService {

    private final NewsMapper newsMapper;

    @Override
    public Page<News> page(Page page, Map<String, Object> map) {
        QueryWrapper<News> wrapper = new QueryWrapper<>();
        wrapper.eq("enable", 0);
        if(Integer.valueOf(map.get("typeQuery").toString())>0){
            wrapper.eq("type", map.get("typeQuery"));
        }
        wrapper.orderByDesc("create_time");
        return page(page, wrapper);
    }

    @Override
    public List<News> getAllFlags() {
        return newsMapper.getAllFlags();
    }
}
